@import 'group';
@import '../../../styles/var';

@checkbox: ~'@{prefix}-checkbox';

.@{checkbox} {
  cursor: pointer;
  line-height: 20px;
  display: inline-block;
  vertical-align: top;
  font-size: 12px;
  font-family: @font-family;
  color: @font-color;

  &.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  &:hover:not(.is-disabled) {
    .@{checkbox}-input {
      border: 1px solid @primary-color;
    }
  }

  &.is-checked {
    .@{checkbox}-input {
      border: 1px solid @primary-color;
    }

    .@{checkbox}-input {
      &:before {
        transform: rotate(45deg) scale(1);
        opacity: 1;
      }
    }
  }

  &:not(.is-disabled) {
    .@{checkbox}-input {
      &:focus {
        border: 1px solid @primary-color;
        box-shadow: @focus-shadow-primary-light;
      }
    }
  }
}

.@{checkbox}-input {
  display: inline-block;
  vertical-align: top;
  width: 14px;
  height: 14px;
  margin: 8px 0;
  border: 1px solid @border-color;
  box-sizing: border-box;
  position: relative;
  background-color: @component-background;

  &:focus {
    outline: none;
  }
}

.@{checkbox}-input {
  &:before {
    opacity: 0;
    margin-top: (12 - @check-height) / 2 - @check-top / 2;
    margin-left: (12 - @check-width) / 2;
    box-sizing: border-box;
    width: @check-width;
    height: @check-height;
    content: '';
    display: block;
    border: 2px solid @primary-color;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) scale(0);
    transition: transform @normal-motion @ease-out-backward;
  }
}

.@{checkbox}-label {
  display: inline-block;
  vertical-align: top;
  padding: 5px;

  &:empty {
    display: none;
  }
}
